home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / c / amiexpress / source / ae / code / ax3.00 / lineinput.c < prev    next >
Encoding:
C/C++ Source or Header  |  1980-01-03  |  5.9 KB  |  307 lines

  1. #include "bbs.h"
  2. extern BYTE DeBuG;
  3. extern int  HistorySelect;
  4. extern UBYTE NumHistItems,WhichHist;
  5. //(JOE) add linecount
  6. extern int LineCount;
  7. long DoHistory=0,LineHasChanged;
  8.  
  9. int LineInput(char *atstart, char *tohere, int maxlen, int time_allowed)
  10. {
  11. int c, x;
  12. LineCount=0;
  13. DoHistory=LineHasChanged=1;
  14.  
  15. x=strlen(atstart);
  16. AEPutStr(atstart);
  17. strcpy(tohere,atstart);
  18. if(Whence_The_Logon==REMOTE_LOGON&&!(c=CheckCarrier()))
  19.     {
  20.     DoHistory=0;
  21.     return(NO_CARRIER);
  22.     }
  23.  
  24. FOREVER
  25.     {
  26.       c=Check_Online_Status();
  27.       if(c<0) return(c);
  28.      c=ReadChar((long)time_allowed);
  29.  
  30.     if(c==NO_CARRIER||c==TIMEOUT) { return(c); }
  31.     if(c==HISTORY)
  32.         {
  33.         LineHasChanged=0;
  34.         while(x)
  35.             {
  36.             AEPutStr("\b \b");
  37.             --x;
  38.             }
  39.         stccpy(tohere,HistoryBuf+(HistorySelect*250),(maxlen<248?maxlen:248)+1);
  40.         x=strlen(tohere);
  41.         AEPutStr(tohere);
  42.         }
  43.     else
  44.         {
  45.           if(c=='\x9b') c='A';
  46.         if(c!='\r')
  47.             {
  48.             LineHasChanged=1;
  49.             }
  50.         if(x<maxlen)
  51.             {
  52.             switch(c)
  53.                 {
  54.                 case '\r': /*  RETURN, IGNORE \n  */
  55.                     tohere[x]='\0';
  56.                     AEPutStr("\r\n");
  57.                     if(CaptureFP)
  58.                         {
  59.                         fprintf(CaptureFP,"%s\n",tohere);
  60.                         }
  61.                     if(DeBuG)
  62.                         {
  63.                         DebugOutput(tohere);
  64.                         }
  65.                     if(x>0&&LineHasChanged)
  66.                         {
  67.                         strcpy(HistoryBuf+(WhichHist*250),tohere);
  68.                         WhichHist++;
  69.                         if(WhichHist==MAXHIST)
  70.                             {
  71.                             WhichHist=0;
  72.                             }
  73.                         HistorySelect=WhichHist;
  74.                         if(NumHistItems<MAXHIST)
  75.                             {
  76.                             NumHistItems++;
  77.                             }
  78.                         /*printf("%s\n",tohere);*/
  79.                         }
  80.                     DoHistory=0;
  81.                     return(x);
  82.                 case '\b': /*  BACKSPACE && DELETE  */
  83.                 case '\177':
  84.                     if(x)
  85.                         {
  86.                         tohere[--x]='\0';
  87.                         AEPutStr("\b \b");
  88.                         }
  89.                     break;
  90.                 case '\30': /*  ^X DELETE LINE */
  91.                     while(x)
  92.                         {
  93.                         AEPutStr("\b \b");
  94.                         --x;
  95.                         }
  96.                     tohere[x]='\0';
  97.                     break;
  98.                 case '\11': /* TAB */
  99.                     if(x%5==0)
  100.                         {
  101.                         tohere[x++]=' ';
  102.                         SendChar(' ');
  103.                         }
  104.                     if(x<(maxlen-5))
  105.                         {
  106.                         while(x%5)
  107.                             {
  108.                             tohere[x++]=' ';
  109.                             SendChar(' ');
  110.                             }
  111.                         }
  112.                     break;
  113.                 case 2:
  114.                     NumHistItems=0;
  115.                     WhichHist=0;
  116.                     HistorySelect=0;
  117.                     break;
  118.                 default:
  119.                     if(c<' ') { break; } /* CONTROL FILTER */
  120.                     tohere[x++]=(char)c;
  121.                     SendChar(c);
  122.                     break;
  123.                 }
  124.             }
  125.         else
  126.             {
  127.             switch(c)
  128.                 {
  129.                 case '\r': /*  RETURNS  */
  130.                     tohere[x]='\0';
  131.                     AEPutStr("\r\n");
  132.                     if(CaptureFP)
  133.                         {
  134.                         fprintf(CaptureFP,"%s\n",tohere);
  135.                         }
  136.                     if(DeBuG)
  137.                         {
  138.                         DebugOutput(tohere);
  139.                         }
  140.                     if(x>0&&LineHasChanged)
  141.                         {
  142.                         strcpy(HistoryBuf+(WhichHist*250),tohere);
  143.                         WhichHist++;
  144.                         if(WhichHist==MAXHIST)
  145.                             {
  146.                             WhichHist=0;
  147.                             }
  148.                         HistorySelect=WhichHist;
  149.                         if(NumHistItems<MAXHIST)
  150.                             {
  151.                             NumHistItems++;
  152.                             }
  153.                         }
  154.                     DoHistory=0;
  155.                     return(x);
  156.                 case '\b': /*  BACKSPACES  */
  157.                 case '\177':
  158.                     tohere[--x]='\0';
  159.                     AEPutStr("\b \b");
  160.                     break;
  161.                 case '\30': /*  ^X  */
  162.                     while(x)
  163.                         {
  164.                         AEPutStr("\b \b");
  165.                         --x;
  166.                         }
  167.                     tohere[x]='\0';
  168.                     break;
  169.                 }
  170.             }
  171.         }
  172.     }
  173. return(SUCCESS);
  174. }
  175.  
  176. #ifdef RTS_OLDSHIT
  177. int LineInput(char *atstart, char *tohere, int maxlen, int time_allowed)
  178. {
  179. int c, x;
  180. LineCount=0;
  181.  DoHistory=LineHasChanged=1;
  182.  
  183.  x=strlen(atstart);
  184.  AEPutStr(atstart);
  185.  strcpy(tohere,atstart);
  186.  
  187.  if(Whence_The_Logon==REMOTE_LOGON&&!(c=CheckCarrier())) {
  188.      DoHistory=0;
  189.         return(NO_CARRIER);
  190.     }
  191.  
  192.  FOREVER    {
  193.      c=Check_Online_Status();
  194.         if(c<0) return(c);
  195.      c=ReadChar((long)time_allowed);
  196.         if(c==NO_CARRIER||c==TIMEOUT)  return(c);
  197.      if(c==HISTORY)    {
  198.          LineHasChanged=0;
  199.             while(x) {
  200.              AEPutStr("\b \b");
  201.                 --x;
  202.             }
  203.             stccpy(tohere,HistoryBuf+(HistorySelect*250),(maxlen<248?maxlen:248)+1);
  204.          x=strlen(tohere);
  205.             AEPutStr(tohere);
  206.         } else    {
  207.          if(c!='\r')    {
  208.              LineHasChanged=1;
  209.             }
  210.             if(x<maxlen) {
  211.              switch(c) {
  212.                  case '\r': /*  RETURN, IGNORE \n  */
  213.                         tohere[x]='\0';
  214.                         AEPutStr("\r\n");
  215.                         if(CaptureFP)
  216.                          fprintf(CaptureFP,"%s\n",tohere);
  217.                      if(DeBuG)
  218.                          DebugOutput(tohere);
  219.                      if(x>0&&LineHasChanged)    {
  220.                          strcpy(HistoryBuf+(WhichHist*250),tohere);
  221.                             WhichHist++;
  222.                             if(WhichHist==MAXHIST)
  223.                              WhichHist=0;
  224.                          HistorySelect=WhichHist;
  225.                             if(NumHistItems<MAXHIST)
  226.                              NumHistItems++;
  227.                             /*printf("%s\n",tohere);*/
  228.                         }
  229.                         DoHistory=0;
  230.                         return(x);
  231.                     case '\b': /*  BACKSPACE && DELETE  */
  232.                     case '\177':
  233.                         if(x) {
  234.                          tohere[--x]='\0';
  235.                             AEPutStr("\b \b");
  236.                         }
  237.                         break;
  238.                     case '\30': /*  ^X DELETE LINE */
  239.                         while(x) {
  240.                          AEPutStr("\b \b");
  241.                             --x;
  242.                         }
  243.                         tohere[x]='\0';
  244.                         break;
  245.                     case '\11': /* TAB */
  246.                         if(x%5==0)    {
  247.                          tohere[x++]=' ';
  248.                             SendChar(' ');
  249.                         }
  250.                         if(x<(maxlen-5)) {
  251.                          while(x%5)    {
  252.                              tohere[x++]=' ';
  253.                                 SendChar(' ');
  254.                             }
  255.                         }
  256.                         break;
  257.                     case 2:
  258.                         NumHistItems=0;
  259.                         WhichHist=0;
  260.                      HistorySelect=0;
  261.                         break;
  262.                     default:
  263.                         if(c<' ') { break; } /* CONTROL FILTER */
  264.                         tohere[x++]=(char)c;
  265.                         SendChar(c);
  266.                      break;
  267.                 }
  268.             } else {
  269.              switch(c) {
  270.                  case '\r': /*  RETURNS  */
  271.                         tohere[x]='\0';
  272.                         AEPutStr("\r\n");
  273.                         if(CaptureFP)
  274.                         fprintf(CaptureFP,"%s\n",tohere);
  275.                      if(DeBuG)
  276.                          DebugOutput(tohere);
  277.                      if(x>0&&LineHasChanged)    {
  278.                          strcpy(HistoryBuf+(WhichHist*250),tohere);
  279.                             WhichHist++;
  280.                             if(WhichHist==MAXHIST)
  281.                              WhichHist=0;
  282.                          HistorySelect=WhichHist;
  283.                             if(NumHistItems<MAXHIST)
  284.                              NumHistItems++;
  285.                         }
  286.                      DoHistory=0;
  287.                         return(x);
  288.                     case '\b': /*  BACKSPACES  */
  289.                     case '\177':
  290.                         tohere[--x]='\0';
  291.                         AEPutStr("\b \b");
  292.                      break;
  293.                     case '\30': /*  ^X  */
  294.                         while(x) {
  295.                          AEPutStr("\b \b");
  296.                             --x;
  297.                         }
  298.                         tohere[x]='\0';
  299.                         break;
  300.                 }
  301.             }
  302.         }
  303.     }
  304.  return(SUCCESS);
  305. }
  306. #endif
  307.